Release 10.1A: OpenEdge Development:
Programming Interfaces
Using the PUT statement
The
PUTstatement is another useful 4GL element for generating reports, especially when you want to customize certain parts of a report. ThePUTstatement has no default framing services, making it useful for writing data to a file or overriding default framing. SincePUThas no framing defaults, your procedures must contain explicit code for formatting your output.The
PUTstatement outputs data one field at a time and uses the format of the field or variable. To include line breaks in the output, you must use theSKIPoption. Additionally, theUNFORMATTEDoption ofPUTdisplays all the data of the field or variable, regardless of format and without spaces between fields.Why would you use
PUTinstead ofDISPLAY? For everyDISPLAYstatement, Progress needs a frame. To execute aDISPLAYstatement, Progress builds a frame capable of handling the expected output, using default services and your explicit instructions.PUTon the other hand, simply outputs data one line at a time, with no default formatting.DISPLAYis most useful when you want automatic formatting.PUTis most useful when you want complete control over output.This is a partial syntax for the
PUTstatement:
One common task that the
PUTstatement can help with is mailing labels. Since mailing labels must conform to a compact physical layout and be uniform, usingPUTis a good idea. Suppose that the All Around Sports accounting department wants to send notices to customers with large balances. They need a procedure that creates mailing labels for the notices.
![]()
To see an example that uses the
PUTstatement:Here is the code for this procedure:
This procedure contains the following points of interest:
To improve this procedure, you can:
If you run
i-10-12.p, you can see the modified version of this procedure. Here is the code for that version:
This is the output of the procedure:
![]()
The following notes help explain the techniques used in the procedure:
- The first
PUTstatement outputs and formats the part of the mailing label that is common to all labels.- The first
IFstatement determines whether the second address line has data. If it does, it outputs the data.- When you create a character expression, like the one in this
PUTstatement, Progress removes trailing blanks from the fields. So this output tightens up the extra white space that showed up in the first mailing list example.- Finally, the second
IFstatement determines whether there is second address line data. If not, thePUTstatement sends a blank line at the end of the address. This statement keeps the label data together and keeps the individual labels correctly spaced from each other.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |